package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

import com.itheima.commons.pojo.User;
import com.itheima.commons.pojo.Users;
import com.itheima.dubbo.interfaces.UserApi;

import com.itheima.dubbo.mysql.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class UserImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByPhone(String phone) {
        User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getMobile, phone));
        return user;
    }

    @Override
    public User addUser(User user) {
        userMapper.insert(user);
        //插入后，把user返回，user会携带id
        return user;
    }
}
